Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exchange_rate to operation #12

Merged
merged 5 commits into from
Nov 13, 2023
Merged

Add exchange_rate to operation #12

merged 5 commits into from
Nov 13, 2023

Conversation

vnovitskyi
Copy link
Contributor

@vnovitskyi vnovitskyi commented Nov 9, 2023

Some Sobank statements include exchange rate. We need to parse the value and apply to a transaction.

@vnovitskyi vnovitskyi marked this pull request as ready for review November 9, 2023 10:42
Copy link
Contributor

@NathanBerthier NathanBerthier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👌

@@ -14,6 +14,7 @@ def self.apply(operation, line)
sign = operation.amount <=> 0 # the detail amount is unsigned

operation.original_amount = sign * BigDecimal(line.detail[4..17]) / (10**scale)
operation.exchange_rate = BigDecimal(line.detail[-4..-1]) / 1000
Copy link
Collaborator

@frantisekrokusek frantisekrokusek Nov 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference the official definition does not state it will always be the exchange rate
image

@@ -14,6 +14,7 @@ def self.apply(operation, line)
sign = operation.amount <=> 0 # the detail amount is unsigned

operation.original_amount = sign * BigDecimal(line.detail[4..17]) / (10**scale)
operation.exchange_rate = BigDecimal(line.detail[-4..-1]) / 1000
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
operation.exchange_rate = BigDecimal(line.detail[-4..-1]) / 1000
operation.exchange_rate = BigDecimal(line.detail[18..52]) / 1000

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 18..52?
not 26..29?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My mistake is should have been this 18..69
You are taking the assumption from 1 single example but the documentation states the last section size is 52 starting position 67-49 = 18

Comment on lines 17 to 18
exchange_rate_value = line.detail[26..29]
operation.exchange_rate = BigDecimal(exchange_rate_value) / 1000 if exchange_rate_value
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are missing the scale of the exchange rate also

Suggested change
exchange_rate_value = line.detail[26..29]
operation.exchange_rate = BigDecimal(exchange_rate_value) / 1000 if exchange_rate_value
exchange_rate_value = line.detail[26..29]
exchange_rate_scale = line.detail[18]
operation.exchange_rate = BigDecimal(exchange_rate_value) / (10**exchange_rate_scale) if exchange_rate_value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@frantisekrokusek make sense. thank
code is updated

@@ -14,6 +14,11 @@ def self.apply(operation, line)
sign = operation.amount <=> 0 # the detail amount is unsigned

operation.original_amount = sign * BigDecimal(line.detail[4..17]) / (10**scale)
exchange_rate_value = line.detail[26..29]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can still be wrong but ok to keep it like that for now

@vnovitskyi vnovitskyi merged commit 12488de into master Nov 13, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants